/*
 * Copyright 2003-2007 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

package com.colony.transport.http;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class ColonyServlet
extends HttpServlet
{
	public static String host;
	public static String user;
	public static String pass;
	public static String _filePath;
	public static String typepath;
	
	public ColonyServlet()
	{
		System.out.println( "Colony Servlet Startup");
	}

	public static String getFilePath()
	{
		return _filePath;
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException 
	{
		_server.processMessage( request, response );
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException
	{
		try
		{
			_server.processMessage( request, response );
		}
		catch (Throwable e)
		{
			e.printStackTrace();
		}
	}
	
	private HttpServer _server;
	
	protected void setBack( HttpServer httpServer )
	{
		_server = httpServer;
	}

	public void init(ServletConfig arg0) 
	throws ServletException 
	{
		super.init(arg0);

		try
		{
			configure();
		}
		catch (ServletException e)
		{
			e.printStackTrace();
		}
	}

	/**
	 * This method must call setBack.  The method should setup
	 * the various parts of Colony ready to use.
	 *
	 */
	public abstract void configure() throws ServletException;
	

}